home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / irsim-ca.2 / irsim-ca / irsim-cap-9.2 / src / irsim / patchfile < prev    next >
Text File  |  1995-05-29  |  11KB  |  428 lines

  1. 23,24c23,24
  2. < #define    LSIZE        2000    /* max size of command line (in chars) */
  3. < #define    MAXARGS        100    /* maximum number of command-line arguments */
  4. ---
  5. > #define    LSIZE        1000000    /* max size of command line (in chars) */
  6. > #define    MAXARGS        50000    /* maximum number of command-line arguments */
  7. 38a39,43
  8. > /* Don't skimp on the space here PLEASE. It causes problems on
  9. > machines where a -short- is just 16 bits (most machines) */
  10. > #if 1
  11. >     int        nmin, nmax;        /* min and max number of arguments */
  12. > #else
  13. 39a45
  14. > #endif
  15. 100a107
  16. > public    int    count_InTrans = FALSE;    /* count INPUT trans. (PEL 4/20/93) */
  17. 103a111,112
  18. > public    FILE    *caplogfile = NULL;    /* log file of cap transitions */
  19. > public    float    totpower = 0;        /* indicative of total power of chip */
  20. 371c380
  21. <     for( i = 0, s = "0ux1lUXhLUXH"; s[i] != '\0'; i++ )
  22. ---
  23. >     for( i = 0, s = "0ux1lUXhHUXL"; s[i] != '\0'; i++ )
  24. 800a810,835
  25. > /*
  26. >  * set/clear captrace bit in node
  27. >  */
  28. > private int xcaptrace( n, flag )
  29. >   nptr  n;
  30. >   char  *flag;
  31. >   {
  32. >     UnAlias( n );
  33. >     if( n->nflags & MERGED )
  34. >       {
  35. >     lprintf( stdout, "can't trace %s\n", pnode( n ) );
  36. >     return( 1 );
  37. >       }
  38. >     if( *flag == '+' )
  39. >     n->nflags |= CAPWATCHED;
  40. >     else if( n->nflags & CAPWATCHED )
  41. >       {
  42. >     lprintf( stdout, "%s was capwatched; not any more\n", pnode( n ) );
  43. >     n->nflags &= ~CAPWATCHED;
  44. >       }
  45. >     return( 1 );
  46. >   }
  47. 821a857,876
  48. > /*
  49. >  * set/clear captrace bit in vector
  50. >  */
  51. > private int vcaptrace( b, flag )
  52. >   register bptr  b;
  53. >   char           *flag;
  54. >   {
  55. >     register int   i;
  56. >     if( *flag == '+' )
  57. >     b->traced |= CAPWATCHVECTOR;
  58. >     else
  59. >       {
  60. >     for( i = 0; i < b->nbits; i += 1 )
  61. >         b->nodes[i]->nflags &= ~CAPWATCHVECTOR;
  62. >     b->traced &= ~CAPWATCHVECTOR;
  63. >       }
  64. >     return( 1 );
  65. >   }
  66. 893a949,1065
  67. >  * Set flag that determines whether transitions on primary inputs will
  68. >  * contribute to overall transition count used to determine total
  69. >  * capacitance charged.  (PEL 5/4/93)
  70. >  */
  71. > private int setinputcap()
  72. >   {
  73. >     if( targc == 1 )
  74. >       {
  75. >     lprintf( stdout, "input capacitance transition accumulator is %s\n",
  76. >       (count_InTrans) ? "ON" : "OFF" );
  77. >     return( 0 );
  78. >       }
  79. >     if( str_eql( "on", targv[1] ) == 0 )
  80. >     count_InTrans = TRUE;
  81. >     else if( str_eql( "off", targv[1] ) == 0 )
  82. >     count_InTrans = FALSE;
  83. >     else
  84. >     error( filename, lineno, "don't know what '%s' means\n", targv[1] );
  85. >     return( 0 );
  86. >   }
  87. > /*
  88. >  * mark nodes and vectors for cap tracing
  89. >  */
  90. > private int setcaptrace()
  91. >   {
  92. >     apply( xcaptrace, vcaptrace, plus_minus );
  93. >     set_vec_nodes( CAPWATCHVECTOR );
  94. >     return( 0 );
  95. >   }
  96. > /*
  97. >  * Helper routine for summing capacitance
  98. >  */
  99. > private int sumcapdoit( n, capsum )
  100. >   register nptr  n;
  101. >   float *capsum;
  102. >   {
  103. >     /* Don't UnAlias() before checking if it's an ALIAS node (PEL 5/31/93) */
  104. >     /* UnAlias( n ); */
  105. >     if( not (n->nflags & (MERGED | ALIAS)) )
  106. >     {
  107. >        *capsum += n->ncap;
  108. >        lprintf( stdout, "%-35s\t\%f\n", pnode( n ), n->ncap);
  109. >     }
  110. >     return( 0 );
  111. >   }
  112. > /*
  113. >  * Helper routine for summing capacitance
  114. >  */
  115. > private int sumcapdoit_eff( n, capsum )
  116. >   register nptr  n;
  117. >   float *capsum;
  118. >   {
  119. >     if ( not (n->nflags & (MERGED | ALIAS)) )
  120. >     *capsum += n->ncap;
  121. >     if( VDD_node != NULL and str_eql( pnode( n ) , pnode( VDD_node ) ) == 0 )
  122. >     *capsum -= n->ncap;
  123. >     if( GND_node != NULL and str_eql( pnode( n ) , pnode( GND_node ) ) == 0 )
  124. >     *capsum -= n->ncap;
  125. >     return( 0 );
  126. >   }
  127. > /*
  128. >  * Print sum of capacitance of nodes
  129. >  */
  130. > private int sumcap()
  131. >   {
  132. >     float capsum = 0;
  133. >     lprintf( stdout, "\nNode \t\t\t\t\t Capacitance (pF)\n" );
  134. >     walk_net( sumcapdoit, (char *) &capsum );
  135. >     lprintf( stdout, "\n Sum of nodal capacitances (including Gnd and Vdd): %f pF",capsum );
  136. >     capsum = 0;
  137. >     walk_net( sumcapdoit_eff, (char *) &capsum );
  138. >     lprintf( stdout, "\n Sum of nodal capacitances: %f pF \n",capsum );
  139. >     return( 0 );
  140. >   }
  141. > /*
  142. >  * Helper routine for zeroing transition counts (PEL 4/30/93). 
  143. >  * Zeros even MERGE and ALIAS node transition counts since this can't
  144. >  * hurt anything.
  145. >  */
  146. > private int zeropowerdoit( n )
  147. >   register nptr  n;
  148. >   {
  149. >     n->trans = 0;
  150. >     n->trans01 = 0.0;    /* PEL 5/3/93 */
  151. >     return( 0 );
  152. >   }
  153. > /*
  154. >  * Zero totpower and transition counts for all nodes (PEL 4/30/93)
  155. >  */
  156. > private int zeropower()
  157. >   {
  158. >     walk_net( zeropowerdoit, (char *) 0 );
  159. >     totpower = 0;
  160. >     return( 0 );
  161. >   }
  162. > /*
  163. 1052,1053c1224,1225
  164. <     if( val == X_X ) val = X;
  165. <     if( n->npot != val )
  166. ---
  167. >     if( n->npot != (val == X_X) ? X : val )
  168. 1858a2031,2032
  169. > public
  170. > #define    REPORT_CAP    0x10
  171. 1866c2040
  172. <     static char  *rep[] = { "decay", "delay", "tau", "tcoord", NULL };
  173. ---
  174. >     static char  *rep[] = { "decay", "delay", "tau", "tcoord", "cap", NULL };
  175. 1920a2095,2281
  176. > /*
  177. >  * Helper routine for printing capacitance totals.
  178. >  */
  179. > private int capsummer( n )
  180. >   register nptr  n;
  181. >   {
  182. >     /* Don't UnAlias() before checking if it's an ALIAS node (PEL 5/31/93) */
  183. >     /* UnAlias( n ); */
  184. >     if( not (n->nflags & (MERGED | ALIAS)) )
  185. >     {
  186. >     lprintf( stdout, " %-35s\t%.3f\t%5d\t%f\t%f\n", 
  187. >         pnode( n ), 
  188. >         n->ncap, 
  189. >         n->trans, 
  190. >         n->trans*n->ncap, 
  191. >         n->trans*n->ncap / totpower);
  192. >     }
  193. >     return( 0 );
  194. >   }
  195. > /*
  196. >  * set up or finish off logfile
  197. >  */
  198. > private int setcaplog()
  199. >   {
  200. >     if( caplogfile != NULL )
  201. >       {
  202. >     (void) fclose( caplogfile );
  203. >     caplogfile = NULL;
  204. >     walk_net( capsummer, (char *) 0 );
  205. >       }
  206. >     if( targc == 2 )
  207. >       {
  208. >     char  *mode = "w";
  209. >     char  *s = targv[1];
  210. >     if( *s == '+' )
  211. >       {
  212. >         s++;
  213. >         mode = "a";
  214. >       }
  215. >     if( (caplogfile = fopen( s, mode )) == NULL )
  216. >     error( filename, lineno, "cannot open log file %s for output\n", s );
  217. >       }
  218. >     return( 0 );
  219. >   }
  220. > /*
  221. >  * Helper routine for capreport().  For a given node, print capacitive node
  222. >  * transition count.  Include node even if it is an ALIAS'd node.  Use nodal
  223. >  * 'naliases' count to distribute node capacitances equally across all
  224. >  * equivalent nodes. (PEL 5/28/93)
  225. >  */ 
  226. > private int capreportdoit( n, CapReportFile )
  227. >   register nptr  n;
  228. >   FILE *CapReportFile;
  229. >   {
  230. >     nptr  root = n;
  231. >     UnAlias( root );
  232. >     if( not (n->nflags & MERGED) )
  233. >       {
  234. >         lprintf( CapReportFile, " %-35s\t%5d\t%.3f\t%f\t%f\n", pnode( n ),
  235. >           root->naliases+1,
  236. >           root->ncap/(root->naliases+1),
  237. >           root->trans01,
  238. >           root->trans01*root->ncap/(root->naliases+1));
  239. >       }
  240. >     return( 0 );
  241. >   }
  242. > /*
  243. >  * Print report of all capacitive node transition counts.  Report includes
  244. >  * all nodes including ALIAS'd nodes.  Capacitances are distributed equally
  245. >  * across all equivalent nodes. (PEL 5/28/93)
  246. >  */ 
  247. > private int capreport()
  248. >   {
  249. >     FILE  *CapReportFile = NULL;    /* file of effective caps. */
  250. >     if( targc == 1 )
  251. >       {
  252. >         walk_net( capreportdoit, (char *) stdout );
  253. >       }
  254. >     else
  255. >       {
  256. >         char  *mode = "w";
  257. >         char  *s = targv[1];
  258. >         if( *s == '+' )
  259. >           {
  260. >             s++;
  261. >             mode = "a";
  262. >           }
  263. >         if( (CapReportFile = fopen( s, mode )) == NULL )
  264. >               error( filename, lineno,
  265. >                  "cannot open capreport file %s for output\n", s );
  266. >         walk_net( capreportdoit, (char *) CapReportFile );
  267. >         fclose( CapReportFile );
  268. >       }
  269. >     return( 0 );
  270. >   }
  271. > /*
  272. >  * Helper routine to compute total capacitance charged.  For a given
  273. >  * node, computes the physical capacitance of that node weighted by the number
  274. >  * of 0->1 transitions on that node, and adds this value to the total
  275. >  * capacitance charged. (PEL 5/3/93)
  276. >  */
  277. > private int effcapsummer( n, capsum )
  278. >   register nptr  n;
  279. >   float *capsum;
  280. >   {
  281. >     char  *nname = pnode( n );
  282. >     char  *is_merge;
  283. >     /* Don't UnAlias() before checking if it's an ALIAS node (PEL 5/31/93) */
  284. >     /* UnAlias( n ); */
  285. >     if( not (n->nflags & (MERGED | ALIAS)) )
  286. >       {
  287. >     *capsum += n->trans01*n->ncap;
  288. >       }
  289. >     return( 0 );
  290. >   }
  291. > /*
  292. >  * Compute the total cap charged.  That is, sum the physical capacitance
  293. >  * of each node weighted by the number of 0->1 transitions on that node
  294. >  * (PEL 5/4/93)
  295. >  */
  296. > private int sumeffcap()
  297. >   {
  298. >     FILE  *CapChgdFile = NULL;    /* file of effective caps. */
  299. >     float capsum = 0;
  300. >     walk_net( effcapsummer, (char *) &capsum );
  301. >     if( targc == 1 )
  302. >       {
  303. >     lprintf( stdout, "Total capacitance charged: %f pF\n", capsum );
  304. >       }
  305. >     else
  306. >       {
  307. >         char  *mode = "w";
  308. >         char  *s = targv[1];
  309. >         if( *s == '+' )
  310. >           {
  311. >             s++;
  312. >             mode = "a";
  313. >           }
  314. >         if( (CapChgdFile = fopen( s, mode )) == NULL )
  315. >           error( filename, lineno, "cannot open cap file %s for output\n", s );
  316. >         fprintf( CapChgdFile, "Total capacitance charged: %f pF\n", capsum );
  317. >         fclose( CapChgdFile );
  318. >       }
  319. >     return( 0 );
  320. >   }
  321. > /*
  322. >  * Output message to file. (PEL 10/7/93)
  323. >  */
  324. > private int dofmsg()
  325. >   {
  326. >     FILE  *MsgFile = NULL;  /* target file for message */
  327. >     int  n;
  328. >     char  *mode = "w";
  329. >     char  *s = targv[1];
  330. >     if( *s == '+' )
  331. >       {
  332. >         s++;
  333. >         mode = "a";
  334. >       }
  335. >     if( (MsgFile = fopen( s, mode )) == NULL )
  336. >       error( filename, lineno, "cannot open file %s for comment\n", s );
  337. >     for( n = 2; n < targc; n += 1 )
  338. >     fprintf( MsgFile, "%s ", targv[n] );
  339. >     fprintf( MsgFile, "\n" );
  340. >     fclose( MsgFile );
  341. >     return( 0 );
  342. >   }
  343. 2158c2519,2520
  344. <     UnAlias( n );
  345. ---
  346. >     /* Don't UnAlias() before checking if it's an ALIAS node (PEL 5/31/93) */
  347. >     /* UnAlias( n ); */
  348. 2217c2579,2580
  349. <     UnAlias( n );
  350. ---
  351. >     /* Don't UnAlias() before checking if it's an ALIAS node (PEL 5/31/93) */
  352. >     /* UnAlias( n ); */
  353. 3384a3708,3723
  354. >     { "caplogfile",    setcaplog,    1,    2,
  355. >       "[[+]file] -> start/stop cap logfile (+file appends to file)"    },
  356. >     { "captrace",    setcaptrace,    2,    MAXARGS,
  357. >       "[-]node/vector... -> start/stop cap tracing specified node/vector(s)"},
  358. >     { "sumcap",        sumcap,        1,    2,
  359. >       "print out sum of capacitances of all nodes"            },
  360. >     { "zeropower",    zeropower,    1,    1,    /* (PEL 4/30/93) */
  361. >       " -> zero current power estimate and nodal transition counts"    },
  362. >     { "sumeffcap",    sumeffcap,    1,    2,    /* (PEL 5/4/93) */
  363. >       "[[+]file] -> output total effective capacitance charged from 0->1"},
  364. >     { "inputcap",    setinputcap,    1,    2,    /* (PEL 5/4/93) */
  365. >       "[on | off] -> enable/disable cap. contribs. from transitions on inputs"},
  366. >     { "capreport",    capreport,    1,    2,    /* (PEL 5/28/93) */
  367. >       "[[+]file] -> report cap. node trans. distributed over all node aliases"},
  368. >     { "fprint",        dofmsg,        2,    MAXARGS, /* (PEL 10/7/93) */
  369. >       "[+]file [text...] -> output specified text to file"},
  370. 3435c3774
  371. <     (void) fprintf( stderr, "[-s] prm_file {sim_file ..} [-cmd_file ..]\n" );
  372. ---
  373. >     (void) fprintf( stderr,"[-s] prm_file {sim_file ..} [-cmd_file ..]\n" );
  374. 3481c3820
  375. <     (void) fprintf( stdout, "*** IRSIM %s ***\n", version );
  376. ---
  377. >     (void) fprintf( stdout, "*** IRSIM-CAP %s ***\n", version );
  378. 3550a3890
  379.